package com.feihong.txgw.ui.activity.user;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.feihong.txgw.R;
import com.feihong.txgw.message.LoginMessage;
import com.feihong.txgw.ui.activity.base.BaseActivity;
import com.feihong.txgw.ui.fragment.home.ShopCarFragment;
import com.feihong.txgw.utils.ScreenUtil;

/**
 * Created by Sabirjan on 2017/8/16.
 * TXGWApp.
 * 飞宏电子
 */

public class MyShopCartActivity extends BaseActivity {

    ShopCarFragment mShoppingCartFragment;
    private ImageView mImgBackBtn;
    private RelativeLayout mTitleLayou;
    private RelativeLayout.LayoutParams mTitleParams;
    @Override
    public void setTheme() {

    }

    @Override
    public int setLayoutID() {
        return R.layout.activity_myshopcart;
    }

    @Override
    public void initView(Bundle savedInstanceState) {

        mImgBackBtn = new ImageView(this);
        mImgBackBtn.setImageDrawable(getResources().getDrawable(R.drawable.btn_back_selector));
        mShoppingCartFragment = findFragment(ShopCarFragment.class);
        if (mShoppingCartFragment == null) {
            mShoppingCartFragment = ShopCarFragment.newInstance("购物车");
        }
        loadRootFragment(R.id.content, mShoppingCartFragment);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mTitleLayou = (RelativeLayout) mShoppingCartFragment.getView().findViewById(R.id.title_layout);
        if(mImgBackBtn.getParent() == null){
            mTitleLayou.addView(mImgBackBtn);
        }
        mTitleParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        mTitleParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        mTitleParams.addRule(RelativeLayout.CENTER_VERTICAL);
        mImgBackBtn.setPadding(ScreenUtil.dip2px(this,10),0,ScreenUtil.dip2px(this,15),0);
        mImgBackBtn.setLayoutParams(mTitleParams);

//        if (mShoppingCartFragment.getView().findViewById(R.id.title_layout) != null) {
//            mShoppingCartFragment.getView().findViewById(R.id.title_layout).setVisibility(View.GONE);
//        }
        mImgBackBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public void bindData() {

    }

    @Override
    public void onUserLogin(LoginMessage loginMessage) {

    }

    @Override
    public void onBackPressedSupport() {
        super.onBackPressedSupport();
    }
}
